<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<?php
session_start();
class Maker extends CI_Controller{
    //put your code here
    
    public function __construct(){
        parent::__construct();
        $this->load->helper('download');
        $this->load->helper("url");
        $this->load->model('Test_model');
        $this->load->model('Check_csv_m');
        $this->load->model('Login_m');
        $this->load->model('Account_m');
        $this->load->helper('form');
        $this->load->model('Mark');
        $this->load->model('Test_model');
        $this->load->model('Download_m');
        $this->load->model('Upload_m');
        $this->load->model('Findpass_m');
        $this->load->model('Export_csv_m');
        $this->load->model('Make_test');
        $this->load->library('email');
        $this->load->model('Readcsvlogin_m');
        $this->load->library('form_validation');
        $this->load->library('session');
        $this->load->library("my_layout"); // Sử dụng thư viện layout
        //$session_data_sm = $this->session->userdata('logged_in_sm');
	//$data['id_sm'] = $session_data_sm['id_sm'];
        $this->my_layout->setLayout("layout/maker_l"); // load file layout chính (view/layout/frontend.php)
        
    }
    // Controller mặc định cho trang chủ
    public function index(){
        $data['title'] = "ホームページ";
        $data['data'] = "ホームページのデータ";
        $session_data_sm = $this->session->userdata('logged_in_mk');
       // $session_data_sm = $this->session->userdata('logged_in_mg');
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        //$this->my_layout->view("frontend/home",$data);
        if($session_data_sm['id_mk']!="")
        {
        $this->my_layout->view("frontend/home",$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function forum(){
        $data['title'] = "フォーラム";
        $session_data_mk = $this->session->userdata('logged_in_mk');
        if($session_data_mk['id_mk']!="")
        {
        $data['manager_mk']=$session_data_mk['manager_mk'];
	$data['id_mk'] = $session_data_mk['id_mk'];
        $this->my_layout->view("frontend/forum",$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function about(){
        $data['title'] = "紹介";
        $session_data_mk = $this->session->userdata('logged_in_mk');
        if($session_data_mk['id_mk']!="")
        {
        $data['manager_mk']=$session_data_mk['manager_mk'];
	$data['id_mk'] = $session_data_mk['id_mk'];
        $this->my_layout->view("frontend/about",$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function setup(){
        $data['title'] = "セットアップ";
        $data['data'] = "セットアップ";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        if($session_data_sm['id_mk']!="")
        {
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $this->my_layout->view("maker/maker_v",$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    function download()
    {
        $data['title']="ダウンロード";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        if($session_data_sm['id_mk']!="")
        {
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['user'] = "maker";
        $this->load->helper(array('form'));
        $this->my_layout->view('download/download_v',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    function verifydownload()
    {
        $data['title']="ダウンロード";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        if($session_data_sm['id_mk']!="")
        {
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $filedown=$this->input->post('filedown');
        $name=$this->Download_m->getCSVfromDB($filedown);
        $data['name']=$name;
        foreach ($name as $rows) {
        ////code hieu
            $session_array_download=array('name'=>$rows->name,'link'=>$rows->link);
            $this->session->set_userdata('download_file',$session_array_download);        
        }
        $this->my_layout->view('download/downfile_v',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }

    public function downfile($id)
    {
        //$session_download = $this->session->userdata('download_file');
        //$test=$session_download['name'];
        //$test=$_GET['STT'];
        $data = file_get_contents("./csv_source/".$id); 
        force_download($id, $data);
    }
    function upload()
    {
        $data['title']="アップロード";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        if($session_data_sm['id_mk']!="")
        {
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        //$data['error']=" ";       
        $this->my_layout->view('upload/upload_form', $data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    function do_upload()
    {
        $data['title']="アップロード";
        $session_data_sm = $this->session->userdata('logged_in_mk');
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $config['upload_path'] = './csv_source/';
        $config['allowed_types'] = 'csv';
        $input_file=$_FILES['userfile']['name'];
        $this->load->library('upload', $config);
        if($session_data_sm['id_mk']!="")
        {
        if ($this->Upload_m->checkCSV($input_file,$session_data_sm['id_mk'])==1) 
        {
            //echo "DKM<br>".$input_file."<br>DKM";
            
            $file_x ="csv_source/".$input_file; 
            //echo $file_x;
            if (file_exists($file_x)) {   
                unlink($file_x); // delete it here only if it exists
                //echo "The file has been deleted"; 
            } 
            $this->upload->do_upload();
            $csv_file_name_again = base_url().'csv_source/'.$input_file;
            $return_array_again = $this->Check_csv_m->_readcsv($csv_file_name_again);
            $data['error_csv']=$return_array_again['CSV_ERROR'];
            $data['csv_file_name']=$csv_file_name_again;
            $data['success_upload']="アップロードが成功";  
            if(count($return_array_again['CSV_ERROR'])>0)
            {
                $this->Upload_m->update_state_error($input_file,1,$session_data_sm['id_mk']);
                $this->my_layout->view('upload/upload_error', $data);
            }
            else
            {
                //$this->Upload_m->insertCSVtoDB($name, $link,0,$session_data_sm['id_mk']);
                $data['csv_data']=$return_array_again['CSV'];
                $this->Upload_m->update_state_error($input_file, 0,$session_data_sm['id_mk']);
                $this->my_layout->view('upload/test_simulation', $data);
            }
            
            
        }  
        else if($this->upload->do_upload())
        {
            $data['data'] = array('upload_data' => $this->upload->data()); 
            $data['success_upload']="アップロードが成功";           
            //$this->my_layout->view('upload/upload_form', $data);
            $upload_data=$this->upload->data();
            $name=$upload_data['file_name'];
            $csv_file_name = base_url().'csv_source/'.$name;
            $return_array = $this->Check_csv_m->_readcsv($csv_file_name);
            $data['error_csv']=$return_array['CSV_ERROR'];
            $data['csv_file_name']=$csv_file_name;
            $link=  base_url().substr($upload_data['full_path'],15);
            if(count($return_array['CSV_ERROR'])>0)
            {
                $checkCSV=$this->Upload_m->check_exist_CSV($name);
                if ($checkCSV==0) 
                {
                    $this->Upload_m->insertCSVtoDB($name, $link,1,$session_data_sm['id_mk']);
                }
                //$this->Upload_m->insertCSVtoDB($name, $link,1,$session_data_sm['id_mk']);
                $this->my_layout->view('upload/upload_error', $data);
            }
            else
            {
                $checkCSV=$this->Upload_m->check_exist_CSV($name);
                if ($checkCSV==0) 
                {
                    $this->Upload_m->insertCSVtoDB($name, $link,0,$session_data_sm['id_mk']);
                }
                //$this->Upload_m->insertCSVtoDB($name, $link,0,$session_data_sm['id_mk']);
                $data['csv_data']=$return_array['CSV'];
                $this->my_layout->view('upload/test_simulation', $data);
            }
        }
        
        else {
            $data['error'] = array('error' => $this->upload->display_errors());
            $this->my_layout->view('upload/upload_form', $data);
        }
        }
        else
        {
            redirect('login_sensei','refresh');
        }
        
    }
    function createLink()
    {
        $data1['title'] = "リンクの作成";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $data1['query']=$this->Make_test->getCSV();
        if($session_data_mk['id_mk']!="")
        {
        $this->my_layout->view('maker/create_link',$data1);
        }
        else
            redirect ('login_sensei','refresh');
    }
    function sendmailtoTester()
    {
        $data1['title'] = "リンクの作成が成功";
        $config['protocol']    = 'smtp';
        $config['smtp_host']    = 'ssl://smtp.gmail.com';
        $config['smtp_port']    = '465';
        $config['smtp_timeout'] = '7';
        $config['smtp_user']    = 't06k53itjp@gmail.com';
        $config['smtp_pass']    = 'hedspit06';
        $config['charset']    = 'utf-8';
        $config['newline']    = "\r\n";
        $config['mailtype'] = 'text'; // or html
        $config['validation'] = TRUE; // bool whether to validate email or not      
        $this->email->initialize($config);
        $i=0;
        $session_data_mk = $this->session->userdata('logged_in_mk');
        $data1['id_mk'] = $session_data_mk['id_mk'];
        $id_mk=$session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $csv_name=$this->input->post('txtCSVName');
        $source_csv = base_url().'csv_source/'.$csv_name;
        $return_array = $this->Check_csv_m->_readcsv($source_csv);
        $manager_name=$session_data_mk['manager_mk'];
        $testtitle=$return_array['CSV']['TestTitle'];
        $testsubtitle=$return_array['CSV']['TestSubTitle'];
        $start_y=$return_array['CSV']['StartDateTime']['YYYY'];
        $start_mo=$return_array['CSV']['StartDateTime']['MM'];
        $start_d=$return_array['CSV']['StartDateTime']['DD'];
        $start_h=$return_array['CSV']['StartDateTime']['h'];
        $start_mi=$return_array['CSV']['StartDateTime']['m'];
        $start_s=$return_array['CSV']['StartDateTime']['s'];
        $start=$start_y."-".$start_mo."-".$start_d."-".$start_h."-".$start_mi."-".$start_s;
        if(isset($return_array['CSV']['EndDateTime']))
        {
        $end_y=$return_array['CSV']['EndDateTime']['YYYY'];
        $end_mo=$return_array['CSV']['EndDateTime']['MM'];
        $end_d=$return_array['CSV']['EndDateTime']['DD'];
        $end_h=$return_array['CSV']['EndDateTime']['h'];
        $end_mi=$return_array['CSV']['EndDateTime']['m'];
        $end_s=$return_array['CSV']['EndDateTime']['s'];
        $end=$end_y."-".$end_mo."-".$end_d."-".$end_h."-".$end_mi."-".$end_s;
        $links=$testsubtitle.":".$manager_name.":".$start.":".$end;
        }
        if(isset($return_array['CSV']['TestTime']))
        {
        $testtime_n=$return_array['CSV']['TestTime']['number'];
        $testtime_u=$return_array['CSV']['TestTime']['unit'];
        $testtime=$testtime_n."-".$testtime_u;
        $links=$testsubtitle.":".$manager_name.":".$start.":".$testtime;
        }
        $testees=$return_array['CSV']['Testees'];
        $link_content = base_url()."login_tester/readLink/".$links;
        $line="\r\n\n";
        $id_pass="";
        for($j=1;$j<=count($testees);$j++)
        {
            if($this->Test_model->check_tester($testees[$j]['ID'],$testsubtitle)->num_rows()==0)
            {
                $this->Test_model->insert_tester($testees[$j]['ID'],$testees[$j]['PW'],$testees[$j]['Name:'],$testsubtitle,$manager_name,$testtitle,$session_data_mk['id_mk']);
            }
            $id_pass=$id_pass."ID:".$testees[$j]['ID']."   Password:".$testees[$j]['PW'].$line;
                
        }
        $Content=$link_content.$line.$id_pass;
        $this->email->from('t06k53itjp@gmail.com','HEDSPI K53 T06');
        $this->email->to('t06k53itjp@gmail.com');
        $this->email->subject('テストのお知らせ');
        $this->email->message($Content);
        if($session_data_mk['id_mk']!="")
        {
            $data1['url_test']=$link_content;
            $data1['id_pass']=$id_pass;
            $data1['test']=$testsubtitle;
            $this->my_layout->view('sendmail/create_link_success',$data1);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function make_test()
    {
        $data1['title'] = "CSV->データベース";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $data1['query']=$this->Make_test->getCSV();
        if($session_data_mk['id_mk']!="")
        {
        $this->my_layout->view('maker/choose_file',$data1);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function csv_to_database()
    {
        $data1['title'] = "CSV->データベース";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $csv_name=$this->input->post('txtCSVName');
        $sess_array_file = array('file_name' => $csv_name);
        $this->session->set_userdata('upload_file_name', $sess_array_file);
        $source_csv=base_url().'csv_source/'.$csv_name;
        $handle = fopen($source_csv, 'r');
        $id_question = 0;
        if($session_data_mk['id_mk']!="")
        {
        if($csv_name=="PTUF01-N01.csv")
        {
            
        while ($data= fgetcsv($handle,","))
        {
           
            if($data[0]=="Q(1)"){
                if($data[1]=="QS") { $qs = $data[2]; $id_question++;}
                else if($data[1]=="S(1)") $s1 = $data[2];
                    else if($data[1]=="S(2)") $s2 = $data[2];
                        else if($data[1]=="S(3)") $s3 = $data[2];
                            else if($data[1]=="S(4)") $s4 = $data[2];
                                else if($data[1]=="S(5)") $s5 = $data[2];
                                    else if($data[1]=="S(6)") $s6 = $data[2];
                                        else if($data[1]=="AN(1)") $an_ks = $data[3];
                else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                    if($this->Export_csv_m->check_question($id_question,'f1_q1')==1)
                    {
                    $this->Export_csv_m->insert_to_f1_q1($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                    $this->Export_csv_m->insert_to_compare("f1_q1",$id_question);
                    }
                    else
                    {
                    $this->Export_csv_m->update_f1_q1($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                    $this->Export_csv_m->update_compare("f1_q1",$id_question);
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;$an_ks=NULL;$sc=NULL;
                }
            }

            else if($data[0]=="Q(2)"){
                if($data[1]=="QS") { $qs = $data[2];$id_question++;}
                    else if($data[1]=="S(1)") $s1 = $data[2];
                        else if($data[1]=="S(2)") $s2 = $data[2];
                            else if($data[1]=="S(3)") $s3 = $data[2];
                                else if($data[1]=="S(4)") $s4 = $data[2];
                                    else if($data[1]=="S(5)") $s5 = $data[2];
                                        else if($data[1]=="S(6)") $s6 = $data[2];
                                            else if($data[1]=="AN(1)") $an_kso = $data[3].",".$data[4];
                                                else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                    if($this->Export_csv_m->check_question($id_question,'f1_q2')==1)
                    {
                    $this->Export_csv_m->insert_to_f1_q2($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_kso,$sc);
                    $this->Export_csv_m->insert_to_compare("f1_q2",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f1_q2($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_kso,$sc);
                        $this->Export_csv_m->update_compare("f1_q2",$id_question);
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;$an_kso=NULL;$sc=NULL;
                }
            }
            else if($data[0]=="Q(3)"){
                if($data[1]=="QS") { $qs = $data[2];$id_question++;}
                    else if($data[1]=="S(1)") $s1 = $data[2];
                        else if($data[1]=="S(2)") $s2 = $data[2];
                            else if($data[1]=="S(3)") $s3 = $data[2];
                                else if($data[1]=="S(4)") $s4 = $data[2];
                                    else if($data[1]=="S(5)") $s5 = $data[2];
                                        else if($data[1]=="S(6)") $s6 = $data[2];
                                            else if($data[1]=="AN(1)") $an_ksa = $data[3].",".$data[4];
                                                else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                    if($this->Export_csv_m->check_question($id_question,'f1_q3')==1)
                    {
                    $this->Export_csv_m->insert_to_f1_q3($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ksa,$sc);
                    $this->Export_csv_m->insert_to_compare("f1_q3",$id_question);
                    }
                    else
                    {
                      $this->Export_csv_m->update_f1_q3($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ksa,$sc);
                        $this->Export_csv_m->update_compare("f1_q3",$id_question);  
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;$an_ksa=NULL;$sc=NULL;
                }
            }
   
                
            else if($data[0]=="Q(4)"){
                if($data[1]=="QW") { $qw = $data[2]; $id_question++;}
                    else if($data[1]=="WR(1)") $wr1 = $data[2];
                        else if($data[1]=="AN(1)") $an1_kw = $data[3];
                            else if($data[1]=="AN(2)") $an2_kw = $data[3];
                                else if($data[1]=="SC(1)"&&$data[2]=="AN(1)") $sc_an1 = $data[3];
                                    else if($data[1]=="SC(2)"&&$data[2]=="AN(2)") $sc_an2 = $data[3];
                if(isset($sc_an2))
                {
                   if($this->Export_csv_m->check_question($id_question,'f1_q4')==1)
                    {
                    $this->Export_csv_m->insert_to_f1_q4($id_question,$qw,$wr1,$an1_kw,$an2_kw,$sc_an1,$sc_an2);
                    $this->Export_csv_m->insert_to_compare("f1_q4",$id_question);
                    }
                    else
                    {
                       $this->Export_csv_m->update_f1_q4($id_question,$qw,$wr1,$an1_kw,$an2_kw,$sc_an1,$sc_an2);
                        $this->Export_csv_m->update_compare("f1_q4",$id_question); 
                    }
                    $qw=NULL;$wr1=NULL;$an1_kw=NULL;$an2_kw=NULL;$sc_an1=NULL;$sc_an2=NULL;
                }
            }
            
            else if($data[0]=="Q(5)"){
                
                if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                            else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                                else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                                    else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s5;echo "</br>";}
                                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s6;echo "</br>";}
                                            else if($data[1]=="S(7)") {$s7=$data[2];}// echo $s7;echo "</br>";}
                                                else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                                                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                                                        else if($data[1]=="AN(3)") {$an3_ksa=$data[3].",".$data[4];}// echo $an3_ksa;echo "</br>";}
                                                            else if($data[1]=="AN(4)") {$an4_kso=$data[3].",".$data[4].",".$data[5].",".$data[6].",".$data[7];}// echo $an4_kso;echo "</br>";}
                                                                else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                                                                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                                                                        else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                                                                            else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                if(isset($sc4))
                {
                   if($this->Export_csv_m->check_question($id_question,'f1_q5')==1)
                    {
                        $this->Export_csv_m->insert_to_f1_q5($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$s7,
                        $an1_ks,$an2_ks,$an3_ksa,$an4_kso,$sc1,$sc2,$sc3,$sc4);
                        $this->Export_csv_m->insert_to_compare("f1_q5",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f1_q5($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$s7,
                        $an1_ks,$an2_ks,$an3_ksa,$an4_kso,$sc1,$sc2,$sc3,$sc4);
                        $this->Export_csv_m->update_compare("f1_q5",$id_question);
                        
                       
                    }
                    $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                    $s4=NULL;$s5=NULL;$s6=NULL;$s7=NULL;
                    $an1_ks=NULL;$an2_ks=NULL;$an3_ksa=NULL;$an4_kso=NULL;
                    $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                }
            }
            
           
            
            else if($data[0]=="Q(6)"){
                
                
                if($data[1]=="QW") { $qw = $data[2];$id_question++;}
                    else if($data[1]=="WR(1)") {$wr1 = $data[2]; }//echo $wr1;}
                    else if($data[1]=="WR(2)") {$wr2 = $data[2]; }
                    else if($data[1]=="WR(3)") {$wr3 = $data[2]; }//echo $wr3;}
                    else if($data[1]=="WR(4)") {$wr4 = $data[2]; }
                    else if($data[1]=="WR(5)") {$wr5 = $data[2]; }
                    else if($data[1]=="WR(6)") {$wr6 = $data[2]; }
                    else if($data[1]=="WR(7)") {$wr7 = $data[2]; }
                    else if($data[1]=="WR(8)") {$wr8 = $data[2]; }
                    else if($data[1]=="WR(9)") {$wr9 = $data[2]; }
                    else if($data[1]=="WR(10)") {$wr10 = $data[2]; }
                    else if($data[1]=="AN(1)") {$an1_kwpo = $data[3].",".$data[4].",".$data[5]; }//echo $an1_kwpo;}
                    else if($data[1]=="AN(2)") {$an2_kwp = $data[3]; }//echo $an2_kwpo."</br>";}
                    else if($data[1]=="AN(3)") {$an3_kwpo = $data[3].",".$data[4].",".$data[5]; }//echo $an3_kwpo."</br>";}
                    else if($data[1]=="AN(4)") {$an4_kwpo = $data[3].",".$data[4]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(5)") {$an5_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(6)") {$an6_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(7)") {$an7_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(8)") {$an8_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(9)") {$an9_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(10)") {$an10_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="ANC") {$anc = $data[2].",".$data[3].",".$data[4].",".$data[5].",".$data[6].",".$data[7].",".$data[8].",".$data[9].",".$data[10].",".$data[11]; }
                    else if($data[1]=="SC(1)") {$sc1 = $data[3]; }//echo $sc1."</br>";}
                    else if($data[1]=="SC(2)") {$sc2 = $data[3]; }//echo $sc2."</br>";}
                    else if($data[1]=="SC(3)") {$sc3 = $data[3]; }//echo $sc3."</br>";}
                    else if($data[1]=="SC(4)") {$sc4 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(5)") {$sc5 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(6)") {$sc6 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(7)") {$sc7 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(8)") {$sc8 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(9)") {$sc9 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(10)") {$sc10 = $data[3]; }//echo $sc4."</br>";}
                if(isset($sc10))
                {   
                    if($this->Export_csv_m->check_question($id_question,'f1_q6')==1)
                    {
                   $this->Export_csv_m->insert_to_f1_q6($id_question,$qw,$wr1,$wr2,$wr3,$wr4,$wr5,$wr6,$wr7,$wr8,$wr9,$wr10,
                    $an1_kwpo,$an2_kwp,$an3_kwpo,$an4_kwpo,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                    $anc,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10);
                   $this->Export_csv_m->insert_to_compare("f1_q6",$id_question);
                    }
                    else
                    {
                      $this->Export_csv_m->update_f1_q6($id_question,$qw,$wr1,$wr2,$wr3,$wr4,$wr5,$wr6,$wr7,$wr8,$wr9,$wr10,
                        $an1_kwpo,$an2_kwp,$an3_kwpo,$an4_kwpo,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                        $anc,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10);
                    $this->Export_csv_m->update_compare("f1_q6",$id_question);  
                    }
                    $qw=NULL; $wr1=NUll;$wr2=NULL;$wr3=NULL;$wr4=NULL;$wr5=NULL;$wr6=NULL;$wr7=NULL;$wr8=NULL;$wr9=NULL;$wr10=NULL;
                    $an1_kwpo=NULL;$an2_kwp=NULL;$an3_kwpo=NULL;$an4_kwpo=NULL;$an5_kwp=NULL;
                    $an6_kwp=NULL;$an7_kwp=NULL;$an8_kwp=NULL;$an9_kwp=NULL;$an10_kwp=NULL;
                    $anc=NULL;$sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;$sc5=NULL;
                            $sc6=NULL;$sc7=NULL;$sc8=NULL;$sc9=NULL;$sc10=NULL;
                   
                } 
            }
               else if($data[0]=="Q(7)"){
                
                
                if($data[1]=="QW") { $qw = $data[2];$id_question++;}
                    else if($data[1]=="WR(1)") {$wr1 = $data[2]; }//echo $wr1;}
                    else if($data[1]=="WR(2)") {$wr2 = $data[2]; }
                    else if($data[1]=="WR(3)") {$wr3 = $data[2]; }//echo $wr3;}
                    else if($data[1]=="WR(4)") {$wr4 = $data[2]; }
                    else if($data[1]=="WR(5)") {$wr5 = $data[2]; }
                    else if($data[1]=="WR(6)") {$wr6 = $data[2]; }
                    else if($data[1]=="WR(7)") {$wr7 = $data[2]; }
                    else if($data[1]=="WR(8)") {$wr8 = $data[2]; }
                    else if($data[1]=="WR(9)") {$wr9 = $data[2]; }
                    else if($data[1]=="WR(10)") {$wr10 = $data[2]; }
                    else if($data[1]=="AN(1)") {$an1_kwp = $data[3]; }//echo $an1_kwpo;}
                    else if($data[1]=="AN(2)") {$an2_kwp = $data[3]; }//echo $an2_kwpo."</br>";}
                    else if($data[1]=="AN(3)") {$an3_kwp = $data[3]; }//echo $an3_kwpo."</br>";}
                    else if($data[1]=="AN(4)") {$an4_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(5)") {$an5_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(6)") {$an6_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(7)") {$an7_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(8)") {$an8_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(9)") {$an9_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(10)") {$an10_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="ANC") {$anc = $data[2].",".$data[3].",".$data[4].",".$data[5].",".$data[6].",".$data[7].",".$data[8].",".$data[9].",".$data[10].",".$data[11]; }
                    else if($data[1]=="SC(1)") {$sc1 = $data[3]; }//echo $sc1."</br>";}
                    else if($data[1]=="SC(2)") {$sc2 = $data[3]; }//echo $sc2."</br>";}
                    else if($data[1]=="SC(3)") {$sc3 = $data[3]; }//echo $sc3."</br>";}
                    else if($data[1]=="SC(4)") {$sc4 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(5)") {$sc5 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(6)") {$sc6 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(7)") {$sc7 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(8)") {$sc8 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(9)") {$sc9 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(10)") {$sc10 = $data[3]; }//echo $sc4."</br>";}
                if(isset($sc10))
                {   
                    if($this->Export_csv_m->check_question($id_question,'f1_q7')==1)
                    {
                   $this->Export_csv_m->insert_to_f1_q7($id_question,$qw,$wr1,$wr2,$wr3,$wr4,$wr5,$wr6,$wr7,$wr8,$wr9,$wr10,
                    $an1_kwp,$an2_kwp,$an3_kwp,$an4_kwp,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                    $anc,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10);
                   $this->Export_csv_m->insert_to_compare("f1_q7",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f1_q7($id_question,$qw,$wr1,$wr2,$wr3,$wr4,$wr5,$wr6,$wr7,$wr8,$wr9,$wr10,
                    $an1_kwp,$an2_kwp,$an3_kwp,$an4_kwp,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                    $anc,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10);
                   $this->Export_csv_m->update_compare("f1_q7",$id_question);
                    }
                    $qw=NULL; $wr1=NUll;$wr2=NULL;$wr3=NULL;$wr4=NULL;$wr5=NULL;$wr6=NULL;$wr7=NULL;$wr8=NULL;$wr9=NULL;$wr10=NULL;
                    $an1_kwp=NULL;$an2_kwp=NULL;$an3_kwp=NULL;$an4_kwp=NULL;$an5_kwp=NULL;
                    $an6_kwp=NULL;$an7_kwp=NULL;$an8_kwp=NULL;$an9_kwp=NULL;$an10_kwp=NULL;
                    $anc=NULL;$sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;$sc5=NULL;
                            $sc6=NULL;$sc7=NULL;$sc8=NULL;$sc9=NULL;$sc10=NULL;
                   
                } 
            }
         }
                $data1['manager_mk']=$session_data_mk['manager_mk'];
                $query4=$this->Test_model->find_max_ques_f1();
                $data1['max_ques']=$query4->num_rows();
                $query=$this->Test_model->type_table_ques(1);
                foreach($query->result() as $row)
                {
                    $q=$row->q;
                }
                $query1=$this->Test_model->get_content_ques($q,1);
                 if($q=="f1_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f1',$data1);
                }
                else if($q=="f1_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f1',$data1);
                }
                else if($q=="f1_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f1',$data1);
                }
                else if($q=="f1_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f1',$data1);
                }
                else if($q=="f1_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f1',$data1);
                }
                else if($q=="f1_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f1',$data1);
                }
                else if($q=="f1_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f1',$data1);
                }
        }
        else if($csv_name=="PTUF02-N01.csv")
        {
             while ($data= fgetcsv($handle,","))
        {
           
            if($data[0]=="Q(1)"){
                if($data[1]=="QS") { $qs = $data[2]; $id_question++;}
                else if($data[1]=="S(1)") $s1 = $data[2];
                    else if($data[1]=="S(2)") $s2 = $data[2];
                        else if($data[1]=="S(3)") $s3 = $data[2];
                            else if($data[1]=="S(4)") $s4 = $data[2];
                                else if($data[1]=="S(5)") $s5 = $data[2];
                                    else if($data[1]=="S(6)") $s6 = $data[2];
                                        else if($data[1]=="AN(1)") $an_ks = $data[3];
                else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                    if($this->Export_csv_m->check_question($id_question,'f2_q1')==1)
                    {
                        $this->Export_csv_m->insert_to_f2_q1($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                        $this->Export_csv_m->insert_to_compare("f2_q1",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f2_q1($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                        $this->Export_csv_m->update_compare("f2_q1",$id_question);
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;$an_ks=NULL;$sc=NULL;
                }
            }

            else if($data[0]=="Q(2)"){
                if($data[1]=="QS") { $qs = $data[2];$id_question++;}
                    else if($data[1]=="S(1)") $s1 = $data[2];
                        else if($data[1]=="S(2)") $s2 = $data[2];
                            else if($data[1]=="S(3)") $s3 = $data[2];
                                else if($data[1]=="S(4)") $s4 = $data[2];
                                    else if($data[1]=="S(5)") $s5 = $data[2];
                                        else if($data[1]=="S(6)") $s6 = $data[2];
                                            else if($data[1]=="AN(1)") $an1_ksa = $data[3].",".$data[4];
                                            else if($data[1]=="AN(2)") $an2_ksa = $data[3].",".$data[4];
                                            else if($data[1]=="AN(3)") $an3_ksa = $data[3].",".$data[4];
                                                else if($data[1]=="SC(1)") $sc1 = $data[3];
                                                else if($data[1]=="SC(2)") $sc2 = $data[3];
                                                else if($data[1]=="SC(3)") $sc3 = $data[3];
                if(isset($sc3))
                {
                    if($this->Export_csv_m->check_question($id_question,'f2_q2')==1)
                    {
                    
                        $this->Export_csv_m->insert_to_f2_q2($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an1_ksa,$an2_ksa,$an3_ksa,$sc1,$sc2,$sc3);
                        $this->Export_csv_m->insert_to_compare("f2_q2",$id_question);
                    }
                    else
                    {
                        
                        $this->Export_csv_m->update_f2_q2($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an1_ksa,$an2_ksa,$an3_ksa,$sc1,$sc2,$sc3);
                        $this->Export_csv_m->update_compare("f2_q2",$id_question);
                        
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;
                    $an1_ksa=NULL;$an2_ksa=NULL;$an3_ksa=NULL;$sc1=NULL;$sc2=NULL;$sc3=NULL;
                }
            }
            if($data[0]=="Q(3)"){
                if($data[1]=="QS") { $qs = $data[2]; $id_question++;}
                else if($data[1]=="S(1)") $s1 = $data[2];
                    else if($data[1]=="S(2)") $s2 = $data[2];
                        else if($data[1]=="S(3)") $s3 = $data[2];
                            else if($data[1]=="S(4)") $s4 = $data[2];
                                else if($data[1]=="S(5)") $s5 = $data[2];
                                    else if($data[1]=="S(6)") $s6 = $data[2];
                                        else if($data[1]=="AN(1)") $an_ks = $data[3];
                else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                    if($this->Export_csv_m->check_question($id_question,'f2_q3')==1)
                    {
                    $this->Export_csv_m->insert_to_f2_q3($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                    $this->Export_csv_m->insert_to_compare("f2_q3",$id_question);
                    
                    }
                    else
                    {
                        $this->Export_csv_m->update_f2_q3($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$an_ks,$sc);
                    
                        $this->Export_csv_m->update_compare("f2_q3",$id_question);
                    }
                    $qs=NULL; $s1=NUll;$s2=NULL;$s3=NULL;$s4=NULL;$s5=NULL;$s6=NULL;$an_ks=NULL;$sc=NULL;
                }
            }
                
            else if($data[0]=="Q(4)"){
                if($data[1]=="QW") { $qw = $data[2]; $id_question++;}
                    else if($data[1]=="WR(1)") $wr = $data[2];
                        else if($data[1]=="AN(1)") $an_kwa = $data[3];
                            else if($data[1]=="SC(1)") $sc = $data[3];
                if(isset($sc))
                {
                   if($this->Export_csv_m->check_question($id_question,'f2_q4')==1)
                   {
                    $this->Export_csv_m->insert_to_f2_q4($id_question,$qw,$wr,$an_kwa,$sc);
                   
                    $this->Export_csv_m->insert_to_compare("f2_q4",$id_question);
                   }
                   else
                   {
                       $this->Export_csv_m->update_f2_q4($id_question,$qw,$wr,$an_kwa,$sc);
                   
                       $this->Export_csv_m->update_compare("f2_q4",$id_question);
                   }
                    $qw=NULL;$wr=NULL;$an_kwa=NULL;$sc=NULL;
                }
            }
            
            else if($data[0]=="Q(5)"){
                
                if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2].",".$data[4];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2].",".$data[4];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2].",".$data[4];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2].",".$data[4];}// echo $s4;echo "</br>";}
                    else if($data[1]=="S(5)") {$s5=$data[2].",".$data[4];}// echo $s5;echo "</br>";}
                    else if($data[1]=="S(6)") {$s6=$data[2].",".$data[4];}// echo $s6;echo "</br>";}
                    else if($data[1]=="S(7)") {$s7=$data[2].",".$data[4];}// echo $s7;echo "</br>";}
                    else if($data[1]=="S(8)") {$s8=$data[2].",".$data[4];}// echo $s7;echo "</br>";}
                        else if($data[1]=="AN(1)") {$an1_ksa=$data[3].",".$data[4]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="AN(2)") {$an2_ksa=$data[3].",".$data[4];}// echo $an2_ks;echo "</br>";}
                        else if($data[1]=="AN(3)") {$an3_ksa=$data[3].",".$data[4];}// echo $an3_ksa;echo "</br>";}
                        else if($data[1]=="AN(4)") {$an4_ksa=$data[3].",".$data[4];}// echo $an4_kso;echo "</br>";}
                        else if($data[1]=="AN(5)") {$an5_ksa=$data[3].",".$data[4];}// echo $an4_kso;echo "</br>";}
                            else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                            else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                            else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                            else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                            else if($data[1]=="SC(5)") {$sc5=$data[3];}// echo $sc4;echo "</br>";}
                if(isset($sc5))
                {
                   if($this->Export_csv_m->check_question($id_question,'f2_q5')==1)
                   {
                    $this->Export_csv_m->insert_to_f2_q5($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,
                    $an1_ksa,$an2_ksa,$an3_ksa,$an4_ksa,$an5_ksa,$sc1,$sc2,$sc3,$sc4,$sc5);
                   
                    $this->Export_csv_m->insert_to_compare("f2_q5",$id_question);
                   }
                   else
                   {
                       $this->Export_csv_m->update_f2_q5($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,
                    $an1_ksa,$an2_ksa,$an3_ksa,$an4_ksa,$an5_ksa,$sc1,$sc2,$sc3,$sc4,$sc5);
                   
                       $this->Export_csv_m->update_compare("f2_q5",$id_question);
                   }
                    $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                    $s4=NULL;$s5=NULL;$s6=NULL;$s7=NULL;$s8=NULL;
                    $an1_ksa=NULL;$an2_ksa=NULL;$an3_ksa=NULL;$an4_ksa=NULL;$an5_ksa=NULL;
                    $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;$sc5=NULL;
                }
            }
            
           else if($data[0]=="Q(6)"){
                if($data[1]=="QW") { $qw = $data[2]; $id_question++;}
                    else if($data[1]=="WR(1)") $wr = $data[2];
                        else if($data[1]=="INS") $ins = "";
                            else if($data[1]=="SC(1)") $sc = 0;
                if(isset($sc))
                {
                   if($this->Export_csv_m->check_question($id_question,'f2_q6')==1)
                   {
                    $this->Export_csv_m->insert_to_f2_q6($id_question,$qw,$wr,$ins,$sc);
                    $this->Export_csv_m->insert_to_compare("f2_q6",$id_question);
                   }
                   else
                   {
                      $this->Export_csv_m->update_f2_q6($id_question,$qw,$wr,$ins,$sc); 
                      $this->Export_csv_m->update_compare("f2_q6",$id_question); 
                   }
                    $qw=NULL;$wr=NULL;$ins=NULL;$sc=NULL;
                }
            }
               else if($data[0]=="Q(7)"){
                
                
                if($data[1]=="QW") { $qw = $data[2];$id_question++;}
                    else if($data[1]=="WR(1)") {$wr = $data[2]; }//echo $wr1;}
                    else if($data[1]=="AN(1)") {$an1_kwpo = $data[3].",".$data[4]; }//echo $an1_kwpo;}
                    else if($data[1]=="AN(2)") {$an2_kwp = $data[3]; }//echo $an2_kwpo."</br>";}
                    else if($data[1]=="AN(3)") {$an3_kwp = $data[3]; }//echo $an3_kwpo."</br>";}
                    else if($data[1]=="AN(4)") {$an4_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(5)") {$an5_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(6)") {$an6_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(7)") {$an7_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(8)") {$an8_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(9)") {$an9_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="AN(10)") {$an10_kwp = $data[3]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="INS") {$ins = " "; }
                    else if($data[1]=="SC(1)") {$sc1 = $data[3]; }//echo $sc1."</br>";}
                    else if($data[1]=="SC(2)") {$sc2 = $data[3]; }//echo $sc2."</br>";}
                    else if($data[1]=="SC(3)") {$sc3 = $data[3]; }//echo $sc3."</br>";}
                    else if($data[1]=="SC(4)") {$sc4 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(5)") {$sc5 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(6)") {$sc6 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(7)") {$sc7 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(8)") {$sc8 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(9)") {$sc9 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(10)") {$sc10 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(11)") {$sc11 =" "; $check=1;}//echo $sc4."</br>";}
                if(isset($check))
                {   
                    if($this->Export_csv_m->check_question($id_question,'f2_q7')==1)
                    {
                   $this->Export_csv_m->insert_to_f2_q7($id_question,$qw,$wr,
                    $an1_kwpo,$an2_kwp,$an3_kwp,$an4_kwp,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                    $ins,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10,$sc11);
                   $this->Export_csv_m->insert_to_compare("f2_q7",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f2_q7($id_question,$qw,$wr,
                    $an1_kwpo,$an2_kwp,$an3_kwp,$an4_kwp,$an5_kwp,$an6_kwp,$an7_kwp,$an8_kwp,$an9_kwp,$an10_kwp,
                    $ins,$sc1,$sc2,$sc3,$sc4,$sc5,$sc6,$sc7,$sc8,$sc9,$sc10,$sc11);
                        $this->Export_csv_m->update_compare("f2_q7",$id_question);
                    }
                    $qw=NULL; $wr=NUll;
                    $an1_kwpo=NULL;$an2_kwp=NULL;$an3_kwp=NULL;$an4_kwp=NULL;$an5_kwp=NULL;
                    $an6_kwp=NULL;$an7_kwp=NULL;$an8_kwp=NULL;$an9_kwp=NULL;$an10_kwp=NULL;
                    $ins=NULL;$sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;$sc5=NULL;
                            $sc6=NULL;$sc7=NULL;$sc8=NULL;$sc9=NULL;$sc10=NULL;$check=NULL;
                   
                } 
            }
            else if($data[0]=="Q(8)"){
                
                
                if($data[1]=="QW") { $qw = $data[2];$id_question++;}
                    else if($data[1]=="WR(1)") {$wr1 = $data[2]; }//echo $wr1;}
                    else if($data[1]=="WR(2)") {$wr2 = $data[2]; }
                    else if($data[1]=="WR(3)") {$wr3 = $data[2]; }//echo $wr3;}
                    else if($data[1]=="AN(1)") {$an1_kwpo = $data[3].",".$data[4]; }//echo $an1_kwpo;}
                    else if($data[1]=="AN(2)") {$an2_kwpo = $data[3].",".$data[4]; }//echo $an2_kwpo."</br>";}
                    else if($data[1]=="AN(3)") {$an3_kwpo = $data[3].",".$data[4]; }//echo $an3_kwpo."</br>";}
                    else if($data[1]=="AN(4)") {$an4_kwpo = $data[3].",".$data[4]; }//echo $an4_kwpo."</br>";}
                    else if($data[1]=="ANC") {$anc = $data[2].",".$data[3].",".$data[4].",".$data[5]; }
                    else if($data[1]=="INS") $ins=" ";
                    else if($data[1]=="SC(1)") {$sc1 = $data[3]; }//echo $sc1."</br>";}
                    else if($data[1]=="SC(2)") {$sc2 = $data[3]; }//echo $sc2."</br>";}
                    else if($data[1]=="SC(3)") {$sc3 = $data[3]; }//echo $sc3."</br>";}
                    else if($data[1]=="SC(4)") {$sc4 = $data[3]; }//echo $sc4."</br>";}
                    else if($data[1]=="SC(5)") {$sc5 = " "; $check=1;}//echo $sc4."</br>";}
                    
                if(isset($check))
                {   
                    if($this->Export_csv_m->check_question($id_question,'f2_q8')==1)
                    {
                    $this->Export_csv_m->insert_to_f2_q8($id_question,$qw,$wr1,$wr2,$wr3,
                    $an1_kwpo,$an2_kwpo,$an3_kwpo,$an4_kwpo,
                    $anc,$ins,$sc1,$sc2,$sc3,$sc4,$sc5);
                    $this->Export_csv_m->insert_to_compare("f2_q8",$id_question);
                    }
                    else
                    {
                        $this->Export_csv_m->update_f2_q8($id_question,$qw,$wr1,$wr2,$wr3,
                    $an1_kwpo,$an2_kwpo,$an3_kwpo,$an4_kwpo,
                    $anc,$ins,$sc1,$sc2,$sc3,$sc4,$sc5);
                        $this->Export_csv_m->update_compare("f2_q8",$id_question); 
                    }
                    $qw=NULL; $wr1=NUll;$wr2=NULL;$wr3=NULL;
                    $an1_kwpo=NULL;$an2_kwpo=NULL;$an3_kwpo=NULL;$an4_kwpo=NULL;
                    $anc=NULL;$ins=NULL;$sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;$sc5=NULL;$check=NULL;
                              
                } 
            }
         }
                $data1['manager_mk']=$session_data_mk['manager_mk'];
                $query4=$this->Test_model->find_max_ques_f2();
                $data1['max_ques']=$query4->num_rows();
                $query=$this->Test_model->type_table_ques1(1);
                foreach($query->result() as $row)
                {
                    $q=$row->q;
                }
                $query1=$this->Test_model->get_content_ques($q,1);
                 if($q=="f2_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f2',$data1);
                }
                else if($q=="f2_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f2',$data1);
                }
                else if($q=="f2_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f2',$data1);
                }
                else if($q=="f2_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f2',$data1);
                }
                else if($q=="f2_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f2',$data1);
                }
                else if($q=="f2_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f2',$data1);
                }
                else if($q=="f2_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f2',$data1);
                }
                else if($q=="f2_q8")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q8_v_f2',$data1);
                }
        }
        else if($csv_name=="PTFX01-N01.csv"){
            while($data=fgetcsv($handle,","))
            {
                if($data[0]=="Q(1)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,1,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else 
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(2)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,2,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(3)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,3,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(4)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,4,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(5)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,5,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(6)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,6,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(7)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,7,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(8)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,8,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(9)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,9,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
                else if($data[0]=="Q(10)"){
                    if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                    else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                    else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                    else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                    else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                    else if($data[1]=="AN(1)") {$an1_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                    else if($data[1]=="AN(2)") {$an2_ks=$data[3];}// echo $an2_ks;echo "</br>";}
                    else if($data[1]=="AN(3)") {$an3_ks=$data[3];}// echo $an3_ksa;echo "</br>";}
                    else if($data[1]=="AN(4)") {$an4_ks=$data[3];}// echo $an4_kso;echo "</br>";}
                    else if($data[1]=="SC(1)") {$sc1=$data[3];}// echo $sc1;echo "</br>";}
                    else if($data[1]=="SC(2)") {$sc2=$data[3];}// echo $sc2;echo "</br>";}
                    else if($data[1]=="SC(3)") {$sc3=$data[3];}// echo $sc3;echo "</br>";}
                    else if($data[1]=="SC(4)") {$sc4=$data[3];}// echo $sc4;echo "</br>";}
                    if(isset($sc4))
                    {
                   
                        if($this->Export_csv_m->check_question($id_question,'x1_q')==1)
                        {
                            $this->Export_csv_m->insert_to_x1_q($id_question,$qs,10,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
                        else
                        {
                            $this->Export_csv_m->update_x1_q($id_question,$qs,$s1,$s2,$s3,$s4,
                            $an1_ks,$an2_ks,$an3_ks,$an4_ks,$sc1,$sc2,$sc3,$sc4);
                        }
//                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                        $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                        $s4=NULL;
                        $an1_ks=NULL;$an2_ks=NULL;$an3_ks=NULL;$an4_ks=NULL;
                        $sc1=NULL;$sc2=NULL;$sc3=NULL;$sc4=NULL;
                    }
                }
            }
            $data1['manager_mk']=$session_data_mk['manager_mk'];
            $query1=$this->Export_csv_m->select_x1_q_content('x1_q',1);
            $query=$this->Export_csv_m->select_x1_q('x1_q');
            $data1['max_ques']=$query->num_rows();
            $data1['query1']=$query1;
            $this->my_layout->view('tester/simulation_x1',$data1);
        }
            else if($csv_name=="PTFX02-N01.csv")
            {
                while($data=  fgetcsv($handle,",")){
                    if($data[0]=="Q(1)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,1,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(2)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,2,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);  
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(3)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,3,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(4)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,4,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(5)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,5,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(6)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,6,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(7)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,7,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(8)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,8,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(9)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,9,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(10)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="LM") {$TRAP=$data[3].",".$data[5];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x2_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x2_q($id_question,10,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x2_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TRAP,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TRAP=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                }
            $data1['manager_mk']=$session_data_mk['manager_mk'];
            $query1=$this->Export_csv_m->select_x1_q_content('x2_q',1);
            $query=$this->Export_csv_m->select_x1_q('x2_q');
            $data1['max_ques']=$query->num_rows();
            $data1['query1']=$query1;
            $this->my_layout->view('tester/simulation_x2',$data1);
            }
            else if($csv_name=="PTFX03-N01.csv")
            {
                while($data=  fgetcsv($handle,",")){
                    if($data[0]=="Q(1)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,1,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(2)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,2,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(3)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,3,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(4)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,4,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(5)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,5,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(6)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,6,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(7)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,7,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(8)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,8,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(9)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,9,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                    else if($data[0]=="Q(10)"){
                        if($data[1]=="QS") {$qs = $data[2]; $id_question++;}
                        else if($data[1]=="S(1)") {$s1=$data[2];}//echo $s1;echo "</br>";}
                        else if($data[1]=="S(2)") {$s2=$data[2];}//echo $s2;echo "</br>";}
                        else if($data[1]=="S(3)") {$s3=$data[2];}//echo $s3;echo "</br>";}
                        else if($data[1]=="S(4)") {$s4=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(5)") {$s5=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="S(6)") {$s6=$data[2];}// echo $s4;echo "</br>";}
                        else if($data[1]=="TM") {$TM=$data[2].",".$data[3];}
                        else if($data[1]=="AN(1)") {$an_ks=$data[3]; }//echo $an1_ks;echo "</br>";}
                        else if($data[1]=="SC(1)") {$sc=$data[3];}// echo $sc4;echo "</br>";}
                        if(isset($sc))
                        {
                            if($this->Export_csv_m->check_question($id_question,'x3_q')==1)
                            {
                            $this->Export_csv_m->insert_to_x3_q($id_question,10,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);
                            }
                            else
                            {
                            $this->Export_csv_m->update_x3_q($id_question,$qs,$s1,$s2,$s3,$s4,$s5,$s6,$TM,
                            $an_ks,$sc);    
                            }
    //                        $this->Export_csv_m->insert_to_compare("x1_q1",$id_question);
                            $qs=NULL;$s1=NULL;$s2=NULL;$s3=NULL;
                            $s4=NULL;$s5=NULL;$s6=NULL;
                            $TM=NULL;
                            $an_ks=NULL;
                            $sc=NULL;
                        }
                    }
                }
            $data1['manager_mk']=$session_data_mk['manager_mk'];
            $query1=$this->Export_csv_m->select_x1_q_content('x3_q',1);
            $query=$this->Export_csv_m->select_x1_q('x3_q');
            $data1['max_ques']=$query->num_rows();
            $data1['query1']=$query1;
            $this->my_layout->view('tester/simulation_x3',$data1);
            }
        }
        else
        {
            redirect('login_sensei','refresh');
        }
        
        fclose($handle);
    }
    public function sub_ques_x1($id_next)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$id_next-1;
        $sub_ans1=$this->input->post('select');
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                    }
                    else
                    {
                        
                        $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                          
                    }
   
                $querys1=$this->Export_csv_m->select_x1_q_content('x1_q',$id_next);
                $data['query1']=  $querys1;
                $this->my_layout->view('tester/simulation_x1',$data);
        
    }
    public function back_ques_x1($id_back)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$this->input->post('txtID');
        $querys=$this->Export_csv_m->select_x1_q_content('x1_q',$id_back);                  
        $data['query1']=  $querys;
        $this->my_layout->view('tester/simulation_x1',$data);
    }
    public function submit_x1($id_question)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['id_te'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $data['test_sub_title']=$session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data['max_ques']=$query4->num_rows();
        $sub_ans1=$this->input->post('select');
        if($session_data_sm['id_mk']!="")
        {
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                    }
                    else
                    {
                        $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                    }
                    
                    $data['success'] = 1;
                    $query5=$this->Mark->get_qsubmit($session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    $mark=0;
                    $mark_i['mark']=array();
                    foreach($query5->result() as $rows5)
                    {
                        $query6=$this->Mark->get_answerx1_byid($rows5->id_question);
                        foreach($query6->result() as $rows6)
                        {
                            if($rows5->sub_an==$rows6->an1_ks)
                            {
                                $mark=$mark+$rows6->sc1;
                                $mark_i['mark'][$rows5->id_question]=$rows6->sc1;
                            }
                            else if($rows5->sub_an==$rows6->an2_ks)
                            {
                                $mark=$mark+$rows6->sc2;
                                $mark_i['mark'][$rows5->id_question]=$rows6->sc2;
                            }
                            else if($rows5->sub_an==$rows6->an3_ks)
                            {
                                $mark=$mark+$rows6->sc3;
                                $mark_i['mark'][$rows5->id_question]=$rows6->sc3;
                            }
                            else if($rows5->sub_an==$rows6->an4_ks)
                            {
                                $mark=$mark+$rows6->sc4;
                                $mark_i['mark'][$rows5->id_question]=$rows6->sc4;
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                            $data['mark_i']=$mark_i;
                        }
                    }
                    
                    $data['sum_mark']=$mark;    
                    $this->my_layout->view('tester/mark_x1',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function sub_ques_x2($id_next)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x2_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$id_next-1;
        $sub_ans1=$this->input->post('select');
        $sub_time=$this->input->post('time');
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name'],$sub_time);
                    }
                    else
                    {
                        
                        $this->Export_csv_m->insert_answer_ques($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk'],$sub_time);
                          
                    }
   
                $querys1=$this->Export_csv_m->select_x1_q_content('x2_q',$id_next);
                $data['query1']=  $querys1;
                $this->my_layout->view('tester/simulation_x2',$data);
    }
    public function back_ques_x2($id_back)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $query4=$this->Export_csv_m->select_x1_q('x2_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$this->input->post('txtID');
        $querys=$this->Export_csv_m->select_x1_q_content('x2_q',$id_back);                  
        $data['query1']=  $querys;
        $this->my_layout->view('tester/simulation_x2',$data);
    }
    public function submit_x2($id_question)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['id_te'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $data['test_sub_title']=$session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x2_q');
        $data['max_ques']=$query4->num_rows();
        $sub_ans1=$this->input->post('select');
        $sub_time=$this->input->post('time');
        if($session_data_sm['id_mk']!="")
        {
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name'],$sub_time);
                    }
                    else
                    {
                        $this->Export_csv_m->insert_answer_ques($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk'],$sub_time);
                    }
                    
                    $data['success'] = 1;
                    $query5=$this->Mark->get_qsubmit($session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    $mark=0;
                    $mark_i['mark']=array();
                    foreach($query5->result() as $rows5)
                    {
                        $query6=$this->Mark->get_answerx2_byid($rows5->id_question);
                        foreach($query6->result() as $rows6)
                        {
                            $trap=$rows6->TRAP;
                            $trap_array=  explode(",", $trap);
                            $trap_unchange=$trap_array[0];
                            $trap_triangle=$trap_array[1];
                            $trap_sum=$trap_triangle+$trap_unchange;
                            $mark_q=$rows6->sc;
                            if($rows5->sub_an==$rows6->an_ks)
                            {
                                if(($trap_sum-$sub_time)<=$trap_unchange)
                                {
                                $mark=$mark+$mark_q;
                                $mark_i['mark'][$rows5->id_question]=$mark_q;
                                }
                                else
                                {
                                $mark=$mark+($sub_time/$trap_triangle)*$mark_q;
                                $mark_i['mark'][$rows5->id_question]=($sub_time/$trap_triangle)*$mark_q;
                                }
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                            $data['mark_i']=$mark_i;
                        }
                    }
                    
                    $data['sum_mark']=$mark;    
                    $this->my_layout->view('tester/mark_x2',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function sub_ques_x3($id_next)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x3_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$id_next-1;
        $sub_ans1=$this->input->post('select');
        $sub_time=$this->input->post('time');
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name'],$sub_time);
                    }
                    else
                    {
                        
                        $this->Export_csv_m->insert_answer_ques($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk'],$sub_time);
                          
                    }
   
                $querys1=$this->Export_csv_m->select_x1_q_content('x3_q',$id_next);
                $data['query1']=  $querys1;
                $this->my_layout->view('tester/simulation_x3',$data);
    }
    public function back_ques_x3($id_back)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $query4=$this->Export_csv_m->select_x1_q('x3_q');
        $data['max_ques']=$query4->num_rows();
        $id_question=$this->input->post('txtID');
        $querys=$this->Export_csv_m->select_x1_q_content('x3_q',$id_back);                  
        $data['query1']=  $querys;
        $this->my_layout->view('tester/simulation_x3',$data);
    }
    public function submit_x3($id_question)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['id_te'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $data['test_sub_title'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x3_q');
        $data['max_ques']=$query4->num_rows();
        $sub_ans1=$this->input->post('select');
        $sub_time=$this->input->post('time');
        if($session_data_sm['id_mk']!="")
        {
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name'],$sub_time);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name'],$sub_time);
                    }
                    else
                    {
                        $this->Export_csv_m->insert_answer_ques($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk'],$sub_time);
                    }
                    
                    $data['success'] = 1;
                    $query5=$this->Mark->get_qsubmit($session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    $mark=0;
                    $mark_i['mark']=array();
                    foreach($query5->result() as $rows5)
                    {
                        $query6=$this->Mark->get_answerx3_byid($rows5->id_question);
                        foreach($query6->result() as $rows6)
                        {
                            $tm1=$rows6->TM;
                            $tm1_array=  explode(",", $tm1);
                            $tmm=$tm1_array[0];
                            $tms=$tm1_array[1];
                            if($tms=="m")
                            {
                                $tm=$tmm*60;
                            }
                            else if($tms=="s")
                                $tm=$tmm;
                            $mark_q=$rows6->sc;
                            if($rows5->sub_an==$rows6->an_ks)
                            {
                                
                                $mark=$mark+($sub_time/$tm)*$mark_q;
                                $mark_i['mark'][$rows5->id_question]=($sub_time/$tm)*$mark_q;
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                            $data['mark_i']=$mark_i;
                        }
                    }
                    
                    $data['sum_mark']=$mark;    
                    $this->my_layout->view('tester/mark_x3',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function sub_ques_f2($id_next)
    {
        $data1['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data1['id_mk'] = $session_data_sm['id_mk'];
        $data1['manager_mk']=$session_data_sm['manager_mk'];
        $id_te=$session_data_sm['id_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data1['file_name'] = $session_data_csv_file['file_name'];
        $query4=$this->Test_model->find_max_ques_f2();
        $data1['max_ques']=$query4->num_rows();
        $id_question=$id_next-1;
        $sub_ans1=$this->input->post('select');
        $sub_ans_text1=$this->input->post('text1');
        $sub_ans_text2=$this->input->post('text2');
        $sub_ans_text3=$this->input->post('text3');
        $sub_ans_text14=$this->input->post('text14');
        $sub_ans_text15=$this->input->post('text15');
        $sub_ans_text16=$this->input->post('text16');
        $sub_ans3=$this->input->post('checkbox');
        $sub_ans1417=$sub_ans_text14.",".$sub_ans_text15.",".$sub_ans_text16;
        //echo $sub_ans5."・".$sub_ans6."・".$sub_ans7;
        $sub_ans34="";
        for($j=0;$j<count($sub_ans3);$j++)
        {
            $sub_ans34=$sub_ans34.$sub_ans3[$j].",";
        }
        $sub_ans33=  substr($sub_ans34, 0, -1);
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            
                            $id_qsub=$row_an->id_qsub;
                            if($sub_ans1!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text1!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans_text1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans33!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans33,$session_data_csv_file['file_name']);
                                
                            }
                            else if($sub_ans_text2!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans_text2,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text3!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans_text3,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans1417!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1417,$session_data_csv_file['file_name']);
                            }
                            $sub_ans34=NULL;
                        }
                    }
                    else
                    {
                        
                        if($sub_ans1!=NULL)
                            {
                            $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text1!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans_text1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans33!=NULL)
                            {
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans33,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                            }
                            else if($sub_ans_text2!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans_text2,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text3!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans_text3,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans1417!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1417,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']
                                        );
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
              
                    }
                $querys=$this->Test_model->type_table_ques1($id_next);
                foreach($querys->result() as $rows)
                {
                    $q=$rows->q;
                }
                $query1=$this->Test_model->get_content_ques($q,$id_next);
                
                 if($q=="f2_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f2',$data1);
                }
                else if($q=="f2_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f2',$data1);
                }
                else if($q=="f2_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f2',$data1);
                }
                else if($q=="f2_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f2',$data1);
                }
                else if($q=="f2_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f2',$data1);
                }
                else if($q=="f2_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f2',$data1);
                }
                else if($q=="f2_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f2',$data1);
                }
                else if($q=="f2_q8")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q8_v_f2',$data1);
                }
                
    }
    public function back_ques_f2($id_back)
    {
        $data1['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data1['id_mk'] = $session_data_sm['id_mk'];
        $data1['manager_mk']=$session_data_sm['manager_mk'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data1['max_ques']=$query4->num_rows();
        $id_question=$this->input->post('txtID');
        $querys=$this->Test_model->type_table_ques1($id_back);
                foreach($querys->result() as $rows)
                {
                    $q=$rows->q;
                }
                $query1=$this->Test_model->get_content_ques($q,$id_back);
                 if($q=="f2_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f2',$data1);
                }
                else if($q=="f2_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f2',$data1);
                }
                else if($q=="f2_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f2',$data1);
                }
                else if($q=="f2_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f2',$data1);
                }
                else if($q=="f2_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f2',$data1);
                }
                else if($q=="f2_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f2',$data1);
                }
                else if($q=="f2_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f2',$data1);
                }
                else if($q=="f2_q8")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q8_v_f2',$data1);
                }
    }
    public function submit_f2($id_question)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['id_te'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $data['test_sub_title'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data['max_ques']=$query4->num_rows();
        $sub_ans_text14=$this->input->post('text14');
        $sub_ans_text15=$this->input->post('text15');
        $sub_ans_text16=$this->input->post('text16');
        $sub_ans1417=$sub_ans_text14.",".$sub_ans_text15.",".$sub_ans_text16;
        if($session_data_sm['id_mk']!="")
        {
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1417,$session_data_csv_file['file_name']);
                    }
                    else
                    {
                        $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1417,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                    }
                    
                    $data['success'] = 1;
                    $query5=$this->Mark->get_qsubmit($session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    $mark=0;
                    $mark_i['mark']=array();
                    foreach($query5->result() as $rows5)
                    {
                        $text='f2_q';
                        $query_tb=$this->db->query("select * from compare where id_question=$rows5->id_question and q LIKE '".$text."%'");
                        foreach($query_tb->result() as $row1)
                        {
                            $q=$row1->q; 
                        }
                        $this->db->select('*');
                        $this->db->from($q);
                        $this->db->where('id_question',$rows5->id_question);
                        $query_q=$this->db->get();
                        foreach ($query_q->result() as $row_q) {
                        if($q=="f2_q1")
                        {
                            if($rows5->sub_an==$row_q->an_ks)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                        }
                        else if($q=="f2_q2")
                        {
                            if($rows5->sub_an==$row_q->an1_ksa)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($rows5->sub_an==$row_q->an2_ksa)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
                            else if($rows5->sub_an==$row_q->an3_ksa)
                            {
                                $mark=$mark+$row_q->sc3;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc3;
                            }
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            } 
                        }
                        else if($q=="f2_q3")
                        {
                            if($rows5->sub_an==$row_q->an_ks)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
                        else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                        }
                        else if($q=="f2_q4")
                        {
                            if($rows5->sub_an==$row_q->an_kwa)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
              
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                        }
                        else if($q=="f2_q5")
                        {
                            if($rows5->sub_an==$row_q->an1_ksa)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($rows5->sub_an==$row_q->an2_ksa)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
                            else if($rows5->sub_an==$row_q->an3_ksa)
                            {
                                $mark=$mark+$row_q->sc3;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc3;
                            }
                            else if($rows5->sub_an==$row_q->an4_ksa)
                            {
                                $mark=$mark+$row_q->sc4;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc4;
                            }
                            else if($rows5->sub_an==$row_q->an5_ksa)
                            {
                                $mark=$mark+$row_q->sc5;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc5;
                            }
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            } 
                        }
                        else if($q=="f2_q6")
                        {
                            $mark_i['mark'][$rows5->id_question]="採点者要介"; 
                        }
                        else if($q=="f2_q7")
                        {
                            $sub_an_l=  explode(",", $row_q->an1_kwpo);
                            $sub_an1=$sub_an_l[0];
                            $sub_an2=$sub_an_l[1];
                            if($rows5->sub_an==$sub_an1||$rows5->sub_an==$sub_an2)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($rows5->sub_an==$row_q->an2_kwp||$rows5->sub_an==$row_q->an3_kwp||$rows5->sub_an==$row_q->an4_kwp
                            ||$rows5->sub_an==$row_q->an5_kwp||$rows5->sub_an==$row_q->an6_kwp||$rows5->sub_an==$row_q->an7_kwp
                            ||$rows5->sub_an==$row_q->an8_kwp||$rows5->sub_an==$row_q->an9_kwp||$rows5->sub_an==$row_q->an10_kwp)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
         
                            else
                            {
        
                                $mark_i['mark'][$rows5->id_question]="採点者要介"; 
                            }
                        }
                        else if($q=="f2_q8")
                        {
                            $sub_an_l=  explode(",", $rows5->sub_an);
                            $sub_an1=$sub_an_l[0];
                            $sub_an2=$sub_an_l[1];
                            $sub_an3=$sub_an_l[2];
                            $sub_an12=$sub_an1.",".$sub_an2;
                            $sub_an13=$sub_an1.",".$sub_an3;
                            $sub_an23=$sub_an2.",".$sub_an3;
                            if($sub_an12==$row_q->an1_kwpo||$sub_an13==$row_q->an1_kwpo||$sub_an23==$row_q->an1_kwpo)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($sub_an12==$row_q->an2_kwpo||$sub_an13==$row_q->an2_kwpo||$sub_an23==$row_q->an2_kwpo)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
                            else if($sub_an12==$row_q->an3_kwpo||$sub_an13==$row_q->an3_kwpo||$sub_an23==$row_q->an3_kwpo)
                            {
                                $mark=$mark+$row_q->sc3;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc3;
                            }
                            else
                            {
                                $mark_i['mark'][$rows5->id_question]="採点者要介";
                            }
                            
                        }
                        $data['mark_i']=$mark_i;
                    }
                   }
                    $data['sum_mark']=$mark;    
                    $this->my_layout->view('tester/mark_f2',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function sub_ques_f1($id_next)
    {
        $data1['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data1['id_mk'] = $session_data_sm['id_mk'];
        $data1['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data1['file_name'] = $session_data_csv_file['file_name'];
        $query4=$this->Test_model->find_max_ques_f1();
        $data1['max_ques']=$query4->num_rows();
        echo $query4->num_rows();
        $id_question=$id_next-1;
        $sub_ans1=$this->input->post('select');
        $sub_ans_text1=$this->input->post('text1');
        $sub_ans_text2=$this->input->post('text2');
        $sub_ans_text3=$this->input->post('text3');
        $sub_ans_text4=$this->input->post('text4');
        $sub_ans_text5=$this->input->post('text5');
        $sub_ans_text6=$this->input->post('text6');
        $sub_ans_text7=$this->input->post('text7');
        $sub_ans_text8=$this->input->post('text8');
        $sub_ans_text9=$this->input->post('text9');
        $sub_ans_text10=$this->input->post('text10');
        $sub_ans_text11=$this->input->post('text11');
        $sub_ans_text12=$this->input->post('text12');
        $sub_ans_text13=$this->input->post('text13');
        $sub_ans_text14=$this->input->post('text14');
        $sub_ans_text15=$this->input->post('text15');
        $sub_ans_text16=$this->input->post('text16');
        $sub_ans_text17=$this->input->post('text17');
        $sub_ans_text18=$this->input->post('text18');
        $sub_ans_text19=$this->input->post('text19');
        $sub_ans_text20=$this->input->post('text20');
        $sub_ans_text21=$this->input->post('text21');
        $sub_ans3=$this->input->post('checkbox');
        $sub_ans211=$sub_ans_text2.",".$sub_ans_text3.",".$sub_ans_text4.",".$sub_ans_text5
                .",".$sub_ans_text6.",".$sub_ans_text7.",".$sub_ans_text8.",".$sub_ans_text9
                .",".$sub_ans_text10.",".$sub_ans_text11;
        $sub_ans1221=$sub_ans_text12.",".$sub_ans_text13.",".$sub_ans_text14.",".$sub_ans_text15
                .",".$sub_ans_text16.",".$sub_ans_text17.",".$sub_ans_text18.",".$sub_ans_text19
                .",".$sub_ans_text20.",".$sub_ans_text21;
        //echo $sub_ans5."・".$sub_ans6."・".$sub_ans7;
        $sub_ans34="";
        for($j=0;$j<count($sub_ans3);$j++)
        {
            $sub_ans34=$sub_ans34.$sub_ans3[$j].",";
        }
        $sub_ans33=  substr($sub_ans34, 0, -1);
        $data1['sub_ans1']=$sub_ans1;
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            
                            $id_qsub=$row_an->id_qsub;
                            if($sub_ans1!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text1!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans_text1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans33!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans33,$session_data_csv_file['file_name']);
                                
                            }
                            else if($sub_ans211!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans211,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans1221!=NULL)
                            {
                                $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1221,$session_data_csv_file['file_name']);
                            }
                            $sub_ans34=NULL;
                        }
                    }
                    else
                    {
                        
                        if($sub_ans1!=NULL)
                            {
                            $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans_text1!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans_text1,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans33!=NULL)
                            {
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans33,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                            }
                            else if($sub_ans211!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans211,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
                            else if($sub_ans1221!=NULL)
                            {
                                $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1221,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                                //$this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1,$session_data_csv_file['file_name']);
                            }
              
                    }
                $querys=$this->Test_model->type_table_ques($id_next);
                foreach($querys->result() as $rows)
                {
                    $q=$rows->q;
                }
                $query1=$this->Test_model->get_content_ques($q,$id_next);
                
                 if($q=="f1_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f1',$data1);
                }
                else if($q=="f1_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f1',$data1);
                }
                else if($q=="f1_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f1',$data1);
                }
                else if($q=="f1_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f1',$data1);
                }
                else if($q=="f1_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f1',$data1);
                }
                else if($q=="f1_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f1',$data1);
                }
                else if($q=="f1_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f1',$data1);
                }
                
    }
    public function back_ques_f1($id_back)
    {
        $data1['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data1['id_mk'] = $session_data_sm['id_mk'];
        $data1['manager_mk']=$session_data_sm['manager_mk'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data1['max_ques']=$query4->num_rows();
        $id_question=$this->input->post('txtID');
        $querys=$this->Test_model->type_table_ques($id_back);
                foreach($querys->result() as $rows)
                {
                    $q=$rows->q;
                }
                $query1=$this->Test_model->get_content_ques($q,$id_back);
                 if($q=="f1_q1")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q1_v_f1',$data1);
                }
                else if($q=="f1_q2")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q2_v_f1',$data1);
                }
                else if($q=="f1_q3")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q3_v_f1',$data1);
                }
                else if($q=="f1_q4")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q4_v_f1',$data1);
                }
                else if($q=="f1_q5")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q5_v_f1',$data1);
                }
                else if($q=="f1_q6")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q6_v_f1',$data1);
                }
                else if($q=="f1_q7")
                {
                    $data1['query_ques2']=  $query1->result();
                    $this->my_layout->view('tester/q7_v_f1',$data1);
                }
    }
    public function submit_f1($id_question)
    {
        $data['title'] = "シミュレーション";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        $data['id_mk'] = $session_data_sm['id_mk'];
        $data['id_te'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $session_data_csv_file = $this->session->userdata('upload_file_name');
	$data['file_name'] = $session_data_csv_file['file_name'];
        $data['test_sub_title'] = $session_data_csv_file['file_name'];
        $query4=$this->Export_csv_m->select_x1_q('x1_q');
        $data['max_ques']=$query4->num_rows();
        $sub_ans_text12=$this->input->post('text12');
        $sub_ans_text13=$this->input->post('text13');
        $sub_ans_text14=$this->input->post('text14');
        $sub_ans_text15=$this->input->post('text15');
        $sub_ans_text16=$this->input->post('text16');
        $sub_ans_text17=$this->input->post('text17');
        $sub_ans_text18=$this->input->post('text18');
        $sub_ans_text19=$this->input->post('text19');
        $sub_ans_text20=$this->input->post('text20');
        $sub_ans_text21=$this->input->post('text21');
        $sub_ans1221=$sub_ans_text12.",".$sub_ans_text13.",".$sub_ans_text14.",".$sub_ans_text15
                .",".$sub_ans_text16.",".$sub_ans_text17.",".$sub_ans_text18.",".$sub_ans_text19
                .",".$sub_ans_text20.",".$sub_ans_text21;
        if($session_data_sm['id_mk']!="")
        {
        $query2=$this->Export_csv_m->check_submit_x1($id_question,$session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    if($query2->num_rows()>=1)
                    {
                        foreach($query2->result() as $row_an)
                        {
                            $id_qsub=$row_an->id_qsub;
                        }
                        $this->Export_csv_m->update_submit_x1($session_data_sm['id_mk'],$id_qsub,$sub_ans1221,$session_data_csv_file['file_name']);
                    }
                    else
                    {
                        $this->Export_csv_m->insert_answer_ques1_x1($session_data_sm['id_mk'],$id_question,$sub_ans1221,$session_data_csv_file['file_name'],$session_data_sm['manager_mk']);
                    }
                    
                    $data['success'] = 1;
                    $query5=$this->Mark->get_qsubmit($session_data_sm['id_mk'],$session_data_csv_file['file_name']);
                    $mark=0;
                    $mark_i['mark']=array();
                    foreach($query5->result() as $rows5)
                    {
                        $text='f1_q';
                        $query_tb=$this->db->query("select * from compare where id_question=$rows5->id_question and q LIKE '".$text."%'");
                        foreach($query_tb->result() as $row1)
                        {
                            $q=$row1->q; 
                        }
                        $this->db->select('*');
                        $this->db->from($q);
                        $this->db->where('id_question',$rows5->id_question);
                        $query_q=$this->db->get();
                        foreach ($query_q->result() as $row_q) {
                        if($q=="f1_q1")
                        {
                            if($rows5->sub_an==$row_q->an_ks)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            }
                            
                        }
                        else if($q=="f1_q2")
                        {
                            $sub_an_l=  explode(",", $row_q->an_kso);
                            $sub_an1=$sub_an_l[0];
                            $sub_an2=$sub_an_l[1];
                            if($rows5->sub_an==$row_q->an_kso||$rows5->sub_an==$sub_an1||$rows5->sub_an==$sub_an2)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0; 
                            }
                        }
                        else if($q=="f1_q3")
                        {
                            if($rows5->sub_an==$row_q->an_ksa)
                            {
                                $mark=$mark+$row_q->sc;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc;
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0; 
                            }
                        }
                        else if($q=="f1_q4")
                        {
                            if($rows5->sub_an==$row_q->an1_kw)
                            {
                                $mark=$mark+$row_q->sc_an1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc_an1;
                            }
                            else if($rows5->sub_an==$row_q->an2_kw)
                            {
                                $mark=$mark+$row_q->sc_an2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc_an2;
                            }
                            else 
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0;
                            } 
                        }
                        
                        else if($q=="f1_q5")
                        {
                            $sub_an_l=  explode(",", $row_q->an4_kso);
                            $sub_an1=$sub_an_l[0];
                            $sub_an2=$sub_an_l[1];
                            $sub_an3=$sub_an_l[2];
                            $sub_an4=$sub_an_l[3];
                            $sub_an5=$sub_an_l[4];
                            if($rows5->sub_an==$row_q->an1_ks)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($rows5->sub_an==$row_q->an2_ks)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
                            if($rows5->sub_an==$row_q->an3_ksa)
                            {
                                $mark=$mark+$row_q->sc3;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc3;
                            }
                            if(strlen(strstr($row_q->an4_kso,$rows5->sub_an)) > 0)
                            {
                                $mark=$mark+$row_q->sc4;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc4;
                            }
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0; 
                            }
                        }
                        else if($q=="f1_q6")
                        {
                            $sub_an_lo=  explode(",", $row_q->an1_kwpo);
                            $sub_an1o=$sub_an_lo[0];
                            $sub_an2o=$sub_an_lo[1];
                            $sub_an3o=$sub_an_lo[2];
                            $sub_an_lt=  explode(",", $row_q->an3_kwpo);
                            $sub_an1t=$sub_an_lt[0];
                            $sub_an2t=$sub_an_lt[1];
                            $sub_an3t=$sub_an_lt[2];
                            $sub_an_lf=  explode(",", $row_q->an4_kwpo);
                            $sub_an1f=$sub_an_lf[0];
                            $sub_an2f=$sub_an_lf[1];
                            
                            if($rows5->sub_an==$sub_an1o||$rows5->sub_an==$sub_an2o||$rows5->sub_an==$sub_an3o)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
                            else if($rows5->sub_an==$sub_an1f||$rows5->sub_an==$sub_an2f)
                            {
                                $mark=$mark+$row_q->sc4;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc4;
                            }
                            else if($rows5->sub_an==$sub_an1t||$rows5->sub_an==$sub_an2t||$rows5->sub_an==$sub_an3t)
                            {
                                $mark=$mark+$row_q->sc3;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc3;
                            }
                            else if($rows5->sub_an==$row_q->an2_kwp
                            ||$rows5->sub_an==$row_q->an5_kwp||$rows5->sub_an==$row_q->an6_kwp||$rows5->sub_an==$row_q->an7_kwp
                            ||$rows5->sub_an==$row_q->an8_kwp||$rows5->sub_an==$row_q->an9_kwp||$rows5->sub_an==$row_q->an10_kwp)
                            {
                                $mark=$mark+$row_q->sc2;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc2;
                            }
         
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0; 
                            } 
                        }
                        else if($q=="f1_q7")
                        {
                            if($rows5->sub_an==$row_q->an1_kwp||$rows5->sub_an==$row_q->an2_kwp||$rows5->sub_an==$row_q->an3_kwp||$rows5->sub_an==$row_q->an4_kwp
                            ||$rows5->sub_an==$row_q->an5_kwp||$rows5->sub_an==$row_q->an6_kwp||$rows5->sub_an==$row_q->an7_kwp
                            ||$rows5->sub_an==$row_q->an8_kwp||$rows5->sub_an==$row_q->an9_kwp||$rows5->sub_an==$row_q->an10_kwp)
                            {
                                $mark=$mark+$row_q->sc1;
                                $mark_i['mark'][$rows5->id_question]=$row_q->sc1;
                            }
         
                            else
                            {
                                $mark=$mark+0;
                                $mark_i['mark'][$rows5->id_question]=0; 
                            } 
                        }
                       $data['mark_i']=$mark_i; 
                      }  
                   }
                    $data['sum_mark']=$mark;    
                    $this->my_layout->view('tester/mark_f1',$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function mark()
    {
         $data['title'] = "採点者介入のテストリスト";
         $session_data_sm = $this->session->userdata('logged_in_mk');
         $data['id_mk'] = $session_data_sm['id_mk'];
         $data['manager_mk']=$session_data_sm['manager_mk'];
         $query1=$this->Mark->used_bymaker($session_data_sm['id_mk']);
         $data['query']=$query1;
         if($session_data_sm['id_mk']!="")
         {
         $this->my_layout->view('maker/mark_bymaker_v',$data);
         }
         else
         {
             redirect('login_sensei','refresh');
         }
    }
    public function mark_list()
    {
        $data1['title'] = "テストの結果";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $data1['query']=$this->Make_test->get_test();
        if($session_data_mk['id_mk']!="")
        {
        $this->my_layout->view('maker/mark_list_v',$data1);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function view_mark_list()
    {
        $data1['title'] = "テストの結果";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $id_test=$this->input->post('txtCSVName');
        $query=$this->Mark->view_test($id_test,$session_data_mk['id_mk']);
        $data1['query']=$query;
        if($session_data_mk['id_mk']!="")
        {
        $this->my_layout->view('maker/list_mark_test_v',$data1);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
    public function mark_by_maker($str)
    {
        $data1['title'] = "テストの結果";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $array_str=  explode(":", $str);
        $id_question=$array_str[0];
        $id_te=$array_str[1];
        $test_id=$array_str[2];
        $data1['id_question']=$id_question;
        $data1['id_te']=$id_te;
        $data1['test_id']=$test_id;
        if($session_data_mk['id_mk']!="")
        {
        $this->my_layout->view('maker/form_mark_bymaker_v',$data1);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
        
    }
    public function marked_maker()
    {
        $data1['title'] = "テストの結果";
        $session_data_mk = $this->session->userdata('logged_in_mk');
	$data1['id_mk'] = $session_data_mk['id_mk'];
        $data1['manager_mk']=$session_data_mk['manager_mk'];
        $mark_ques=$this->input->post('txtKainyuu');
        $id_te=$this->input->post('txtIDTester');
        $id_question=$this->input->post('txtIDQues');
        $test_id=$this->input->post('txtCSV');
        $test_array=  explode(".", $test_id);
        $testtitle=$test_array[0];
        if($session_data_mk['id_mk']!="")
        {
        $this->Mark->update_mark_bymaker($id_question,$id_te,$test_id,$mark_ques);
        $query=$this->Mark->get_sum_mark($id_te,$testtitle);
        foreach($query->result() as $row)
        {
            $sum_mark_old=$row->sum_mark;
        }
        $sum_mark_new=$sum_mark_old+$mark_ques;
        $this->Mark->update_sum_mark($id_te,$testtitle,$sum_mark_new);
        redirect('maker/mark','refresh');
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }
       //maker＿profile
    public function maker_profile()
    {
         $data['title'] = "プロファイル";
         $session_data_sm = $this->session->userdata('logged_in_mk');
         if($session_data_sm['id_mk']!="")
         {
         $data['manager_mk']=$session_data_sm['manager_mk'];
	 $data['id_mk'] = $session_data_sm['id_mk'];
         $query=$this->Account_m->get_maker($data['id_mk']);
         foreach ($query as $row)
         {
            $data['id_mg']=$row->id_mk;
            $data['email_mg']=$row->email;
            $data['name_mg']=$row->name;
            $data['phone_mg']=$row->phone;
            $data['address_mg']=$row->address;
         }
         $this->my_layout->view("frontend/profile_v",$data);
         }
         else
         {
             redirect('login_sensei','refresh');
         }
         
    }
    //maker_change pass
    public function maker_change_pass()
    {
        $data['title'] = "パスワードの修正";
        $data['user']="maker";
        $session_data_sm = $this->session->userdata('logged_in_mk');
        if($session_data_sm['id_mk']!="")
        {
        $data['manager_mk']=$session_data_sm['manager_mk'];
	$data['id_mk'] = $session_data_sm['id_mk'];
        $this->my_layout->view("frontend/change_pass",$data);
        }
        else
        {
            redirect('login_sensei','refresh');
        }
        
    }
    //maker_change pass
    public function success_change_pass()
    {
        $data['title'] = "パスワードの修正";
        $data['user']="maker";
        $session_data_sm = $this->session->userdata('logged_in_mk');
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $new_pass1=$this->input->post('new_pass');
        $new_pass2=$this->input->post('new_pass_again');
        $old_pass=$this->input->post('old_pass');
        $query= $this->Account_m->search_maker_pass($data['id_mk']);
        if($session_data_sm['id_mk']!="")
        {
        foreach ($query as $row)
         {
            $data['password']=$row->password;        
         }
        if($data['password']!=md5($old_pass))
         {
             $data['error1']="古いパスワードが違う";
             $this->my_layout->view("frontend/change_pass",$data);
         }
        else if($new_pass1!=$new_pass2)
        {
        $data['error']="新しいパスワードと新しいパスワードの重複が違う";
        $this->my_layout->view("frontend/change_pass",$data);
        }
        else
        {
            $this->Account_m->update_maker_pass($data['id_mk'],$new_pass1);            
            echo "<script type='text/javascript'>";	
	    echo "alert ('パスワードを変更しました!!! ');";
	    echo "</script>";
             $this->my_layout->view("frontend/home",$data);
        }
        }
        else
        {
            redirect('login_sensei','refresh');
        }
    }

    public function ranking()
    {
        $data['title'] = "ランキング";
        $session_data_sm = $this->session->userdata('logged_in_mk');
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $data['query1']=$this->Make_test->get_test();
        $this->my_layout->view("maker/ranking_v",$data);
    }
    public function ranking_control()
    {
        $data['title'] = "ランキング";
        $session_data_sm = $this->session->userdata('logged_in_mk');
	$data['id_mk'] = $session_data_sm['id_mk'];
        $data['manager_mk']=$session_data_sm['manager_mk'];
        $testtitle=$this->input->post('txtCSVName');
        $data['testtitle']=$testtitle;
        $data['query']=$this->Make_test->get_Mark($testtitle);
        $this->my_layout->view("maker/ranking_result_v",$data);
    }
    public function logout()
    {
        $session_data_mk = $this->session->userdata('logged_in_mk');
        $id_mk = $session_data_mk['id_mk'];
        $manager_mk = $session_data_mk['manager_mk'];
        $this->Login_m->update_online_mk1($id_mk,$manager_mk,0);
        $this->session->unset_userdata('logged_in_mk');
        session_destroy();
        redirect('login_sensei','refresh');
    }
    
    
}
?>
    </html>